/*
 * @Author: wangliang
 * @Date: 2018-04-27
 * @description: 其他信息
*/

import { apiHttp } from '../../../apiHttp';
import ApiProduct from '../../../../api/company/comProductController.api';
import ApiBusiness from '../../../../api/company/comBusinessController.api';
import ApiCompetitor from '../../../../api/company/comCompetitorController.api';
import { ComProductDto, ComBusinessDto, ComCompetitorDto, JsonResult } from '../../../../api/Interface';
import { ComPBJSearchDto } from '../companyInterface';

export default {
    // 添加产品服务
    saveCompanyProduct: async (comProduct: ComProductDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiProduct.saveCompanyProduct, comProduct);
        return res;
    },
    // 删除产品服务
    deleteCompanyProduct: async (delId: number): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiProduct.deleteCompanyProduct, {id: delId});
        return res;
    },
    // 编辑产品服务
    updateCompanyProduct: async (comProduct: ComProductDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiProduct.updateCompanyProduct, comProduct);
        return res;
    },
    // 根据企业id和运营状态 获取当前企业所有产品服务
    getCompanyProductPage: async (comProductList: ComPBJSearchDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiProduct.getCompanyProductPage, comProductList);
        return res;
    },
    // 产品运营标记为运营
    operativeProducts: async (operativeId: number): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiProduct.operativeProducts, {companyId: operativeId});
        return res;
    },
    // 添加企业业务
    saveComBusiness: async (comBusiness: ComBusinessDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiBusiness.saveComBusiness, comBusiness);
        return res;
    },
    // 编辑企业业务
    updateComBusiness: async (comBusiness: ComBusinessDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiBusiness.updateComBusiness, comBusiness);
        return res;
    },
    // 删除企业业务
    deleteComBusinessById: async (delId: number): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiBusiness.deleteComBusinessById, {id: delId});
        return res;
    },
    // 根据企业id和运营状态 获取当前工商的所有企业业务
    getComBusinessPage: async (comProductList: ComPBJSearchDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiBusiness.getComBusinessPage, comProductList);
        return res;
    },
    // 企业业务运营标记为运营
    operativeBusiness: async (operativeId: number): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiBusiness.operativeBusiness, {companyId: operativeId});
        return res;
    },
    // 添加竞品信息
    saveComCompetitor: async (comCompetitor: ComCompetitorDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiCompetitor.saveComCompetitor, comCompetitor);
        return res;
    },
    // 编辑竞品信息
    updateComCompetitor: async (comCompetitor: ComCompetitorDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiCompetitor.updateComCompetitor, comCompetitor);
        return res;
    },
    // 根据企业id和运营状态 获取当前企业所有竞品信息
    getComCompetitorPage: async (comCompetitor: ComPBJSearchDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiCompetitor.getComCompetitorPage, comCompetitor);
        return res;
    },
    // 删除竞品信息
    deleteComCompetitorById: async (delId: number): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiCompetitor.deleteComCompetitorById, {id: delId});
        return res;
    },
    // 竞品运营标记为运营
    operativeCompetitors: async (operativeId: number): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(ApiCompetitor.operativeCompetitors, {companyId: operativeId});
        return res;
    },
     // 模糊搜索业务
     searchBusiness: async (name: string): Promise<string[]> => {
        const res: JsonResult = await apiHttp(ApiProduct.searchBusiness, {name});
        return res.data;
    },
     // 模糊搜索行业
     searchIndustry: async (name: string): Promise<string[]> => {
        const res: JsonResult = await apiHttp(ApiProduct.searchIndustry, {name});
        return res.data;
    },
     // 模糊搜索类型 产品分类
     searchType: async (name: string): Promise<string[]> => {
        const res: JsonResult = await apiHttp(ApiProduct.searchType, {name});
        return res.data;
    },
};